package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.UserSound;
import com.tanhua.model.mongo.UserSoundTime;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @Description: test
 * @Create by: 熊孩子
 * @Date: 2021/12/11 21:04
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserSoundVo implements Serializable {
    private Integer id;//用户id
    private String avatar; //头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String soundUrl; //语音文件，URL 不能超过10条
    private Integer remainingTimes; //语音接收剩余次数


    public static UserSoundVo init(UserInfo userInfo, UserSound userSound, UserSoundTime userSoundTime) {
        UserSoundVo vo = new UserSoundVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo, vo);
        vo.setId(Math.toIntExact((userInfo.getId())));
        vo.setSoundUrl(userSound.getSoundFileUrl());
        vo.setRemainingTimes(userSoundTime.getRemainingTimes());
        return vo;
    }
}
